 <template>
  <div>
    <canvas ref="qrcodeCanvas"></canvas>
<br/>
   <label style="width: 196px; text-align: center; margin-left: 70px;"> {{ name }}</label>
  </div>
</template>

<script>
import QRCode from 'qrcode'

export default {
   data() {
    return {
            cedex:"",
            name:"",
            xingbie:"",
            dianhua:"",
            xuexing:"",
            bumen:"",
            zhiwu:""

    }
  },
  mounted :function () {
   
 
    this.cedex = this.$route.params.cedex
    this.name = this.$route.params.name
    if(this.$route.params.xingbie==="1"){
      this.xingbie = "女"
    }else{
      this.xingbie = "男"
    }
    
    this.dianhua = this.$route.params.dianhua
    this.xuexing = this.$route.params.xuexing
    this.bumen = this.$route.params.bumen
    this.zhiwu = this.$route.params.zhiwu

    this.generateQRCode('编号:'+this.cedex+';姓名:'+this.name+';电话:'+this.dianhua+';性别:'+this.xingbie+';血型:'+this.xuexing+';部门:'+this.bumen+';职务:'+this.zhiwu+';')
  },
  methods: {
    generateQRCode(text) {
      const canvas = this.$refs.qrcodeCanvas
      QRCode.toCanvas(canvas, text, function (error) {
        if (error) {
          console.error(error)
        }
      })
    }
  }
}
</script>